package school;

interface Contents {
    int i = 0;
    public int value();
}

class Wrapping {
    private int i;

    public Wrapping(int i) {
        this.i = i;
    }

    public int value() {
        return i;
    }
}

public class Parcel {
    void f() { System.out.println("Outer class ***"); }

    public class Inner {
        void f() { System.out.println("Inner class ***"); }
        public Parcel outer() { return Parcel.this; }
    }

    public Contents getContent() {  // 获取匿名内部类
        return new Contents() {
            int i = 11;
            @Override
            public int value() { return i; }
        };
    }

    public Wrapping getWrap(int x) {
//        return new Wrapping(x) {
//            @Override
//            public int value() {
//                return super.value() * 47;
//            }
//        };
        class In extends Wrapping {
            public In(int x) { super(x); }
            public int value() { return super.value() * 47; }
        }
        return new In(x);
    }

    public static class Test {
        public static void main(String[] args) {
            Parcel parcel = new Parcel();
            parcel.f();
            parcel.new Inner().outer().f();
            System.out.println(parcel.new Inner().outer() == parcel);
            System.out.println(parcel.getWrap(10).value());
        }
    }
}
